package com.hm.quartz.task;

import com.hm.manage.autoInspection.VehicleInspection;
import com.hm.manage.domain.Xxxtsimp;
import com.hm.manage.pach.FormatJson;
import com.hm.manage.pach.JsoupTest1;
import com.hm.manage.pach.PostExample;
import com.hm.manage.service.IXxxtsimpService;
import com.hm.manage.utils.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.hm.common.utils.StringUtils;

import java.io.IOException;
import java.math.BigInteger;
import java.util.Date;
import java.util.Map;
import java.util.concurrent.ExecutionException;

/**
 * 定时任务调度测试
 * 
 * @author ruoyi
 */
@Slf4j
@Component("ryTask")
public class RyTask
{
    @Autowired
    private SmsService smsService;

    @Autowired
    private KafkaOffsetLagFetcher kafkaOffsetLagFetcher;

    @Autowired
    private FTPFileService ftpFileService;

    @Autowired
    private SFTPFileService sftpFileService;

    @Autowired
    private VehicleInspection vehicleInspection;

    @Autowired
    private DiskSpaceChecker diskSpaceChecker;

    @Autowired
    private JsoupTest1 jsoupTest1;

    @Autowired
    private PostExample postExample;

    @Autowired
    private FormatJson formatJson;

    @Autowired
    private IXxxtsimpService xxxtsimpService;

    public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i)
    {
        //smsService.sendSms("13915890092","哈哈哈");
        System.out.println(StringUtils.format("执行多参方法： 字符串类型{}，布尔类型{}，长整型{}，浮点型{}，整形{}", s, b, l, d, i));
    }

    public void ryParams(String params)
    {
        System.out.println("执行有参方法：" + params);
    }

    public void ryNoParams()
    {
        System.out.println("执行无参方法");
    }

    public void kafkaService() throws ExecutionException, InterruptedException {
        log.info("-------------定时任务kafkaService开始----------------------");
        Map<Integer, Long> lagMap = kafkaOffsetLagFetcher.getLagMap("50.58.191.82:9092","connector-chain-bayonet_vehiclepass", "BAYONET_VEHICLEPASS");
        int size = lagMap.size();
        kafkaOffsetLagFetcher.checkLagMap(lagMap);
        log.info(lagMap.toString());
        log.info("---------connector-chain-bayonet_vehiclepass消费BAYONET_VEHICLEPASS分片数量：{}----------------------------",size);
        log.info("-------------定时任务kafkaService结束----------------------");
    }

    public void coutFtpFileCount(){
        log.info("-------------定时任务coutFtpFileCount开始----------------------");
        Integer fileCount = ftpFileService.getFileCount("172.18.16.170", 55555, "hik", "wujin320@2019", "/home/hik");
        Integer fileCount2 = ftpFileService.getFileCount("172.18.16.101", 55555, "hik", "wujin320@2019", "/home/hik");
        Integer fileCount3 = ftpFileService.getFileCount("172.18.16.102", 55555, "hik", "wujin320@2019", "/home/hik");
        log.info("-------------文件数量为：{};{};{}----------------------", fileCount, fileCount2, fileCount3);
        log.info("-------------定时任务coutFtpFileCount开始----------------------");
    }

    public void coutSftpFileCount(){
        log.info("-------------coutSftpFileCount开始----------------------");
        Integer fileCount = sftpFileService.getFileCount("172.18.16.170", 55555, "hik", "wujin320@2019", "/home/hik");
        Integer fileCount2 = sftpFileService.getFileCount("172.18.16.101", 55555, "hik", "wujin320@2019", "/home/hik");
        Integer fileCount3 = sftpFileService.getFileCount("172.18.16.102", 55555, "hik", "wujin320@2019", "/home/hik");
        log.info("-------------文件数量为：{};{};{}----------------------", fileCount, fileCount2, fileCount3);
        log.info("-------------coutSftpFileCount结束----------------------");
    }

    public void vehicleInspection(String deptName) {
        log.info("-------------定时任务vehicleInspection开始----------------------");
        vehicleInspection.vehicleInspection(deptName);
        log.info("-------------定时任务vehicleInspection结束----------------------");
    }

    public void hbpDiskCheck(){
        String s = diskSpaceChecker.checkGAHbpDisk();
        log.info("---------------定时任务hbpDiskCheck--------------------------");
        log.info(s);
    }

    public void sendsms(){
        String msg = "异常，最大分片堆积数量为2086517，大于2000,平均为1308273.5";
        msg = msg.replace("{", "").replace("}", "").replace(",","；").replace(":","；").replace(" ","");
        String s = smsService.sendSms("13915890092", msg);
        log.info("----------------------{}",s);
    }

    /***
     * 获取列表信息
     * @throws IOException
     */
    public void jsoupTest() throws IOException {
        log.info("-----------jsoupTest开始-------------");
        int pages = postExample.getPages();
        if (pages > 0) {
            for (int i = 0; i < pages; i++) {
                int pageNum = i+1;
                String list1 = postExample.getList(pageNum, 10);
                formatJson.formatJson(list1);
            }
        }

    }

    public void getDetail(){
        log.info("-----------getDetail开始-------------");
        String detail = postExample.getDetail("320412010001202504281652480000001");
        log.info(detail);
    }

    /***
     * 获取系统信息
     */
    public void insertXxxt(){
        formatJson.HandleAllXtbaxxAndInsert();
    }

    /***
     * 测试单个代码更新3张图片
     */
    public void handleOrgDetail(){
        log.info("-----------handleOrgDetail开始-------------");
        formatJson.handleAllOrgDetail();

    }



}
